package com.sc.search.controller;

import com.sc.common.pojo.CommonResult;
import com.sc.common.utils.ExceptionUtil;
import com.sc.search.service.ItemService;
import org.apache.solr.client.solrj.SolrServerException;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;

/**
 * Created by sc on 2017/10/24.
 */
@Controller
public class ItemController {

    @Autowired
    private ItemService itemService;


    @RequestMapping("/import")
    @ResponseBody
    public CommonResult importAll(){
        try {
           CommonResult result =  itemService.importDataToSolr();
            return result;
        } catch (IOException e) {
            e.printStackTrace();
            return CommonResult.build(500, ExceptionUtil.getStackTrace(e));
        } catch (SolrServerException e) {
            e.printStackTrace();
            return CommonResult.build(500, ExceptionUtil.getStackTrace(e));
        }
    }




}
